package com.vans.micro.user.controller;


import com.vans.api.api.user.UserServiceAPI;
import com.vans.api.feign.order.OrderServiceFeign;
import com.vans.micro.user.service.impl.UserInfoInfoServiceImpl;
import order.OrderInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import user.UserInfoVO;

/**
 * @author QXY
 * @since 2020-10-24
 */
@RestController
public class UserController implements UserServiceAPI {

    @Autowired
    private UserInfoInfoServiceImpl userService;

    @Autowired
    private OrderServiceFeign orderService;

    @Value("${user.name}")
    private String lord;

    @RequestMapping(value ="/index", method = RequestMethod.GET)
    @ResponseBody
    public String index() {
        return "客户尼古拉斯" + lord;
    }

    @Override
    public UserInfoVO getById(@RequestParam(value = "id") Integer id) {
        return userService.getById(id);
    }


    @Override
    public OrderInfoVO getOrderByUser(@RequestParam(value = "id") Integer id) {
        UserInfoVO userVO = userService.getById(id);
        if (null == userVO) return null;
        return orderService.getByUserId(userVO.getId());
    }
}
